package Bean;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Cart<T> {
    public static class CartGood {

        public Integer FurnId;
        public Integer amount;
        public CartGood(){

        }
        public CartGood(Integer furnId, Integer amount) {
            FurnId = furnId;
            this.amount = amount;
        }

        public Integer getFurnId() {
            return FurnId;
        }

        public void setFurnId(Integer furnId) {
            FurnId = furnId;
        }

        public Integer getAmount() {
            return amount;
        }

        public void setAmount(Integer amount) {
            this.amount = amount;
        }

        @Override
        public String toString() {
            return "CartGood{" +
                    "FurnId=" + FurnId +
                    ", amount=" + amount +
                    '}';
        }
    }
    private Integer Userid;
    private CartGood FurnGood;
    private List<CartGood> cartGoods = new ArrayList<>();
    private Integer id;
    private List<T> goods;
    private String keyWord;
    private Integer BeginIndex;

    public List<CartGood> setCarrGoods(List<CartGood> cartGoods){
        this.cartGoods = cartGoods;
        return this.cartGoods;
    }
    public void setFurnGood(Integer FurnId,Integer amount){
        int i =-1;
        for (CartGood cartGood :cartGoods) {
            if (cartGood.FurnId == FurnId){
                cartGood.amount = amount;
                i = 1;
                break;
            }
        }
        if (i == -1){
            CartGood cartGood = new CartGood(FurnId, amount);
            cartGoods.add(cartGood);
        }
    }
    public Class getFurnGoodClass(){
        return CartGood.class;
    }

    public List<CartGood> getCartGoods(){
        return cartGoods;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getUserid() {
        return Userid;
    }

    public void setUserid(Integer userid) {
        Userid = userid;
    }

    public String getKeyWord() {
        return keyWord;
    }

    public void setKeyWord(String keyWord) {
        this.keyWord = keyWord;
    }

    public List<T> getGoods() {
        return goods;
    }

    public void setGoods(List<T> goods) {
        this.goods = goods;
    }

    public Integer getBeginIndex() {
        return BeginIndex;
    }

    public void setBeginIndex(Integer beginIndex) {
        BeginIndex = beginIndex;
    }

    public void addFurn(T furn){
        goods.add(furn);
    }
}
